分类
联系方式
  1. 新浪微博
  2. E-mail

Dart eval:CompilerContext 编译器上下文

介绍

dart_eval 在最初的分析阶段,解析出的内容都位于 CompilerContext 中。后续的编译过程,需要根据这里的上下文再进行输出。

成员

topLevelDeclarationsMap

什么是 Top Level Declarations?表示一些声明(变量、函数、类),它们定义在任何声明之外。换句话说,它们没有内嵌在任何其它声明内部。这些声明就是在最顶层(top-level scope),可以在代码的任何位置中访问。

签名:

Map<int, Map<String, DeclarationOrBridge>> topLevelDeclarationsMap = {};

结构:

  • 外层 Key int:文件标识,每个文件都有一个唯一标识
  • 外层 Value Map
    • 内层 Key String:声明类型名称
    • 内层 Value DeclarationOrBridge:对应的声明内容

instanceDeclarationsMap

签名:

  Map<int, Map<String, Map<String, Declaration>>> instanceDeclarationsMap = {};

结构:

  • 外层 Key int:文件标识,每个文件都有一个唯一标识
  • 外层 Value Map:一个文件里可能定义多个类,所以会有中层 Map
    • 中层 Key String:类名
    • 中层 Value Map:类中的各种声明